/***********************************************************************
 * Module:  TypeEpreuve.java
 * Author:  Alexandro
 * Purpose: Defines the Class TypeEpreuve
 ***********************************************************************/

package dao;

import java.util.*;
import java.sql.*;

public class TypeEpreuve implements InterfaceDAO {
   private int type;
   
   public Epreuve[] totalEpreuves;
   
   public int getType() {
      return type;
   }
   
   /** @param newType */
   public void setType(int newType) {
      type = newType;
   }
   
   public int insert(int[] param) {
   	
        try {			
			dao.DAODataConnection.executer("INSERT INTO type_epreuve "+
										   "VALUES("+getType()+");");											
			return 0;			
			}		
		catch(Exception e){ System.out.println(e); }		
		
		return 1;
		
   }
   
   public Object[] select(int[] param) {
      
          
       try {			
			
			ResultSet table = dao.DAODataConnection.executerQuery("SELECT * FROM type_epreuve");											
			Vector sortie = new Vector();			
			while(table.next() )	
			{
				TypeEpreuve neuf = new TypeEpreuve();
				neuf.setType(table.getInt(1));				
				
				sortie.add(neuf);				
			}		
			return sortie.toArray();			
			}
			
		catch(Exception e){ System.out.println(e); }		
		
		return null;
		
		
   }
   
   public int delete(int[] param) {
      
      try {			
			dao.DAODataConnection.executer("DELETE FROM type_epreuve WHERE type="+getType());											
			return 0;			
			}		
		catch(Exception e){ System.out.println(e); }		
		
		return 1;
		
   }
   
   public int update(int[] param) {
      // TODO: implement
      return 0;
   }

}